import { createStore } from 'vuex'

const store = createStore({
    state() {
        return {
            username: '', // 存储用户名
            email: '',
            id: '',
            avatar: '', // 存储头像 URL
            followersCount: ''
        }
    },
    mutations: {
        setUser(state, userInfo) {
            state.username = userInfo.username
            state.email = userInfo.email
            state.id = userInfo.id
            state.avatar = userInfo.avatar
            state.followersCount = userInfo.followersCount
        }
    },
    actions: {
        setUserInfo({ commit }, userInfo) {
            commit('setUser', userInfo)
        }
    }
})

export default store
